#include <iostream>

using namespace std;

struct LinkNode{
    int val;
    LinkNode* next;
    LinkNode():val(0),next(nullptr){};
    LinkNode(int val):val(val),next(nullptr){};
    LinkNode(int val,LinkNode* next):val(val),next(next){};
};

LinkNode* backLinK(LinkNode* head){
    LinkNode* Head=nullptr;
    LinkNode* pre=head;
    LinkNode* cur;
    while(pre){
        cur=pre->next;
        pre->next=Head;
        Head=pre;
        pre=cur;
    }
    return Head;
}

int main(){
    LinkNode* node1=new LinkNode(1);
    LinkNode* node2=new LinkNode(2);
    LinkNode* node3=new LinkNode(4);
    LinkNode* node4=new LinkNode(4);
    LinkNode* node5=new LinkNode(3);
    node1->next=node2;
    node2->next=node3;
    node3->next=node4;
    node4->next=node5;
    node5->next=nullptr;
    LinkNode* pre=backLinK(node1);
    LinkNode* cur=pre;
    while(cur!=nullptr){
        cout<<"val= "<<cur->val<<endl;
        cur=cur->next;
    }
    return 0;
}